import function,shutil,os
from PIL import Image

def pic_operate(path):
    img=Image.open(path)
    width, height = img.size
    name=os.path.basename(path)
    if(width>3000):
        new_width=3000
        new_height=int(height*new_width/width)
        path_new="D:/Desk/精画图同步/精画/"+name
        try:
            img=img.resize((new_width,new_height))
            img.save(path_new)
            print(name,'成功了喔')
        except:
            print(name,'失败了喔') 
    else:
        print(name,'无须调整')   
       
    

paths=function.get_file_paths("D:/Desk/精画图同步/精画/")

i=0
for path in paths:
    # if i>2:
    #     break
    pic_operate(path)
    i+=1